package demo06

/**
 * @author xiaoZhao
 * @date 2022/7/11
 * @describe 不可变的Set  不可重复 无序
 */
object Test06_ImmutableSet {
  def main(args: Array[String]): Unit = {
    // 1.创建Set
    val set1 = Set(12,78,90,56,78,12,34,23)
    println(set1)

    set1.foreach(println)

    for (elem <- set1){
      print(elem)
      print("\t")
    }
    // 2。添加元素
    val set2 = set1 + 80
    println(set2)

    // 3。合并set
    val set3 = Set(14,25,46,57,68,91)
    val set4 = set2 ++ set3
    println(set2)
    println(set3)
    println(set4)

    // 4.删除元素
    val set5 = set3 - 14
    println(set3)
    println(set5)
  }
}
